package com.jic.veteran.portal.service.impl;

import cn.hutool.core.util.StrUtil;
import com.jic.veteran.portal.dao.BigScreenDao;
import com.jic.veteran.portal.domain.DonationListDto;
import com.jic.veteran.portal.service.BigScreenService;
import com.jic.veteran.portal.service.UmsMemberCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章管理Service实现类
 * Created by macro on 2018/10/11.
 */
@Slf4j
@Service
public class BigScreenServiceImpl implements BigScreenService {

    @Autowired
    private BigScreenDao bigScreenDao;

    @Autowired
    private UmsMemberCacheService umsMemberCacheService;

    @Override
    public List<DonationListDto> list() {
        List<DonationListDto> donationListDtoList;
        String bigScreenTime = umsMemberCacheService.getBigScreenTime();
        if(StrUtil.isNotEmpty(bigScreenTime)) {
            donationListDtoList = bigScreenDao.listByBigScreenTime(bigScreenTime);
        } else {
            donationListDtoList = bigScreenDao.list();
        }
        return donationListDtoList;
    }

    @Override
    public String payCount() {
        String payCount;
        String bigScreenTime = umsMemberCacheService.getBigScreenTime();
        if(StrUtil.isNotEmpty(bigScreenTime)) {
            payCount = bigScreenDao.payCountByBigScreenTime(bigScreenTime);
        }else {
            payCount = bigScreenDao.payCount();
        }
        return payCount;
    }

    @Override
    public String payAmout() {
        String payAmout;
        String bigScreenTime = umsMemberCacheService.getBigScreenTime();
        if(StrUtil.isNotEmpty(bigScreenTime)) {
            payAmout = bigScreenDao.payAmoutByBigScreenTime(bigScreenTime);
        }else {
            payAmout = bigScreenDao.payAmout();
        }
        return payAmout;
    }
}
